refactor generics library