Fixed error middleware in app