updated aternative of ready function