Error handling and middleware work