added error module and middleware