improve sql update code