refactor codes for pull to update