Void function: a function-definition is not allowed here before '{' token

Posted in my original post. I didn't change anything else apart from the { }s.

//Nextion official library. Only using a selected few.

#include <doxygen.h>
#include <NexButton.h>
#include <NexConfig.h>
#include <NexCrop.h>
#include <NexGauge.h>
#include <NexHardware.h>
#include <NexHotspot.h>
#include <NexObject.h>
#include <NexPage.h>
#include <NexPicture.h>
#include <NexProgressBar.h>
#include <NexSlider.h>
#include <NexText.h>
#include <Nextion.h>
#include <NexTouch.h>
#include <NexWaveform.h>

//DC motor


int motorPin = 3;
int fanSpeed = 100;


//Declare Fan page buttons
NexButton bON = NexButton(3, 3, "bON");
NexButton bOFF = NexButton(3, 4, "bOFF");
NexButton bMenuF = NexButton(3, 6, "bMenuF");
NexButton bFMinus = NexButton(3, 7, "bFMinus");
NexButton bFPlus = NexButton(3, 8, "bFPlus");
NexButton bFMinus2 = NexButton(3, 9, "bFMinus2");
NexButton bFPlus2 = NexButton(3, 10, "bFPlus2");

NexTouch *nex_listen_list[] =
{
  //Declare Fan page buttons
  &bON,
  &bOFF,
  &bMenuF,
  &bFMinus,
  &bFPlus,
  &bFMinus2,
  &bFPlus2,
  NULL
};

// Touch events

void bONPopCallback(void *ptr) {  // Release event for button - Void pointer, allocates memory to previous callback fn.
  analogWrite(motorPin, fanSpeed);  // Turn ON fan
}
void bOFFPopCallback(void *ptr) { // Release event for button
  analogWrite(motorPin, 0);  // Turn OFF fan
}
void bFMinus2PopCallback (void *ptr) {
  if (fanSpeed == HIGH)
    analogWrite(motorPin, 255 / 4); // 25% speed
  else
    analogWrite(motorPin, 0);
}
void bFMinusPopCallback (void *ptr) {
  //fanSpeed = fanSpeed - 5; //Minus 5 to current value of counter - Couldn't get this to work.
  if (fanSpeed == HIGH)
    analogWrite(motorPin, 255 / 2); // 50% speed
  else
    analogWrite(motorPin, 0);
}
void bFPlusPopCallback (void *ptr) {
  //fanSpeed = fanSpeed + 5; //Plus 5 to current value of counter - Couldn't get this to work.
  if (fanSpeed == HIGH)
    analogWrite(motorPin, 255 * 3 / 4); // 75% speed
  else
    analogWrite(motorPin, 0);
}
void bFPlus2PopCallback (void *ptr) {
  if (fanSpeed == HIGH)
    analogWrite(motorPin, 255); // 100% speed
  else
    analogWrite(motorPin, 0);
}

void setup() {
  // put your setup code here, to run once:
  pinMode(motorPin, OUTPUT);
  Serial.begin(9600);
  //Serial.println("Give a number from 50 to 255.");

  //analogWrite(motorPin, 0); //Fan always off when system powered on


  // Register the event callback fns of each touch event
  // Format for press events: <object name>.attachPush(<object name>PushCallback);
  // Format for release events: <object name>.attachPop(<object name>PopCallback);
  bON.attachPop(bONPopCallback);
  bOFF.attachPop(bOFFPopCallback);
  bFMinus.attachPop(bFMinusPopCallback);
  bFPlus.attachPop(bFPlusPopCallback);
  bFMinus2.attachPop(bFMinus2PopCallback);
  bFPlus2.attachPop(bFPlus2PopCallback);
}

void loop() {
  nexLoop (nex_listen_list); //Check for any touch event
}