added median-cut algorithm