Benchmark for better solution:

https://gist.github.com/tinogomes/8332883