moved command pattern into its own class and put it in lib.