Refactor the Command pattern and add corresponding comments.