added some template magic