main: apply ES6 syntax, refactor