move debug calls to better place