added check if entry already exists in the database