Moved debug to document on ready event