Improve document.ready function