refactoring asn generation