Add Command pattern for undo action and refactor onCreate method