implemented remove duplicates for directions