Semi-complete code for update, needs test