fix determination of smallest heading change