move update queries before select queries