added generics; code cleanup