safer record update code