Change from mediator to function