Added duplicate handling for DB