refactored and support generic now