fixes a bug where a constant was incorrect.
also changes the angle calculation as per Alex Herber's suggestions.