fixed stuff

changed atan to atan2 function so it works properly in other quadrants