Move cmd creation to a new function for readability
Don't need to close the cmd channel