code.js refactored