more testing. added test mode. tried middleware