Moved events inside document.ready