Fix use of wrong variables