implementation of command handling