Trying to make more flexible template logic