Posted fixed version of Arjun's script.