Refactoring of trace method