Added waitSafely method