moved delay to outside the ready function.