refactor level.js