fixed cost function to remember dir at end floor