added changeDirection method