Extract command service

This code is just copy pasted