Minor tweak to ascend/descend detection to make it slightly more efficient