allow to add more middlewares + implement error middleware
fix error handling