refactoring of debug print