Better use of generics