correctly inserts into database