templating improved to allow proper printing