refine debug routine for convenient use