adding for update, and better use of reduce