Just put this algorithm together in a couple of minutes.
It's not as good as I expected but it'll get better.