error fix & reduced comparisons