added some direction logic