Added window ready function