Putting protocols and generics to use