fixed stupid error computing direction