generalize templates a bit more