Update cb.js

code refactoring