refactor handleUpdate and rename otherwiseError to onError