added detection to document.ready to see if document was ready before this method was called