fix defined check bugs