adding error handing
adding error handing