moving error handler middleware