Trying to prevent duplicates in database