Fix: Add protection to avoid memory hung