throwing the correct exception on duplicate check