correcting check_vaild_ptr