Improve debug func