Refactoring for deplicated code deletion in getTracesBetweenInterval method