Refactor of doAction