crazy code for while check