Added ability to handle both forward and back cases where there is no change in the vertical coordinate and uppercased the constants