Well, here's a function I made awhile ago that kinda does that , problem is, it USED to work when I last tried it...but now it doesnt....maybe you can take a look at it and fix it :
See fixed version of the code in my next post.