move gen middleware dependencies to the top