slight refactoring of trace