added a check on whether or not the script is empty