Discovered and fixed bugs re: while loop in checkUnit