improve design of debug mode