Refactor actions.js