Refactoring ready.js