 				elapsedTime = calcTime(startTime);
 
 				// Any valid accumulated time will be returned
-				if (startTime > 0 && elapsedTime > freeTime) {
+				if ((startTime > 0) && (freeTime < elapsedTime) && (elapsedTime < 5*quota)) {
           			return elapsedTime;
 				}
 				else {


		// if periodX and periodY IS a valid pair
		if ( signals[i] == 1 ) {
			// a job is detected when we get 5 valid signals in a row
			// begin stopwatch
			if (checkHistory(signals) == flag.detectedJobStart) {
				if (startTime == 0) {
					startTime = millis();
				}

		}
		// if periodX and periodY IS NOT a valid pair
		if ( signals[i] == 0 ) {
			numValid = 0;
			numInvalid += 1;
			// check if enough negative signals have been detected
			// calculate elapsed time
			if (numInvalid == sampleSize) {
				elapsedTime = calcTime(startTime);

				// if a job was detected, return
				if ((startTime > 0) && (freeTime < elapsedTime) && (elapsedTime < 5*quota)) {
					return elapsedTime;
				}
				else {
