ADDED: First working version of script