I'm not seeing why it would be duplicated. I'm probably missing something but it seems like you could remove the "continue" within the if above, and then move the if/else with the throwing logic after the while.