Check script handle correctly

Fix commit 882a05f36252b044a9bbed752328627392e73a8c