Updated to use existing trace code