add angle calculation last to first part
put angle calculation in its own function