Updated UPDATE query for deciding shift