Improved the scripting