Refactor out actions in script