Convert insert node closure to a method
Slight modification to the way middleware is called
Convert insert page closure to a method
Slight change again