Add function to remove duplicates from array