modified ready function