set 404 code for not found
fix middleware ordering