update and refactor