Refactored tracer method. Uses much less code lines now.