revised update/insert query