Refactor the handle() method.