adding error checkign