Detect running state correctly