commit to db only if there is a change