Added RAII scope guard