Finally the script. Bugs included.