Use generics rather than multiple variables