Refactor act() function.