started refactoring ready.js