Fixed bug that saved duplicate entries in the database.