Commented out automatic state-detection logic