added change direction functionality