Fix variable reference problem