Updated to use comparator instead of op amps