Fixed bug in previous head turning algorithm