Added middleware and routes