Check debug level first for optimization