Encapsulate debug logic