moved debugging logic to its module.