modified get_angle() function