fix the turn function