Refactor to use one function per command