fixing undefined variable