added a better and improved version that I'm sure is function. The last one I'm not so certain it works.