Refactor process()