Fixed possible errors in script