trace and debug functionality