generics to reduce similar functions