closure commands.js (refactoring)