moves detection to separate class
adds code comments