cleanup and refactor for update process