refactoring piwik service