Refactored compiler.js