compile.js - refactor