refactor pomelo.js