adding error check