refactor angle computation