added parameter for direction