added code to see if dot product being less than zero was the problem