Added method that checks for duplicates in the database