updated duplicate handling to pass example 2 test