function refactoring / mediaService integration