some refactoring on trace and AS lookup