added fixDuplicates and sortDoses