Fixing undefined variable