refactor execCommand