improve selection and executeCommand