Fixed problem with onReady function