docs and correct middleware order