Fully working detection of states
Faraday 1's working script