Refactor action.php