improved the script by adding error checks