fix a bug in middleware when raise NotFound
add pick_dict in util