Instead of copying this from elsewhere you could also source the other script. That way you won't have to update it on changes...