Try using document.ready