changed order of comparison of directions