changed onRequest to before()