refactoring to use commands and queries