trying to implement templates; still not finished