Fix bug passing wrong variables to template