fix bug in moving middleware