implement Detect

Closes #1.
This definitely looks nicer indented this way.