Fixed onDeviceReady function