precondition on templates instead of if statements