Generics will help with this casting problem