added direction function.