duplicates function is messing up, fixing it