Fixing syntax and script error