fix a few bugs

fix the perpendicular bug