modified turn_90, turn_180 function