add more robust command detection