adding error handing