refactored types and middleware, preparing for profiles display