Refactor commands.js