update #13 and use middleware