added direction vector function