Changed drawing algorithm to use average instead of min/max