Use power of Generics to infer types

in more functions