fix duplicates and errors