Improve perfomance and change algorithm
Comment debug output