added: middleware into the flags