Combined $.ready() functions to resolve scope issues