fixed small error in checking horizontal