Direction feature

fix memory issue