Updating code to use generics