automatically change direction after leaving directory