split main() function from DebugHandler