fixed duplicate for add/update & styled a little

before updating or adding a row to the database I made sure there wasn't
a duplicate before executing the query.