cleaned up code for heading rotation