added Middleware methods to pass database instance in getting studies