fixed algorithm, huge speed increase, but theres a bug in the learning?