define more flexible api for commands and re-organize responsibilities