stackexchange middleware implementation