public void onFrame(Controller controller) {
		Frame frame = controller.frame();

		if (recording) {
			pattern.addFrame(frame);

			if (frameCount > 1 && pattern.justMoved())
				framesNotMoving = 0;
			else
				framesNotMoving++;

			if (framesNotMoving > RECORDING_TIMEOUT) {
				done = true;
				recording = false;
				pattern.endRecording();
				System.out.println("done");
			}

			frameCount++;
		} else if (inStartPosition(frame) && !done)
			recording = true;
	}