Refactored close guard