Refactor handle() to use pattern matching
Add wrapper function to send commands