Fix potential bug in setReady function