make the _id middleware into it's own function

Signed-off-by: Tomas Neme <lacrymology@gmail.com>