Use cli plugin and refactor this into a service