removes the duplicates preserving the order