implementation of command pattern