Created service

I have refactored the functionality into a service, which the controller plugin calls.
This is a much better way to do it, because it makes it available through the service locator.