expansion of angle calculation function