This is similar to the script I wrote a few years ago but unlike that one, this solution doesn't kill the performance.