boolean condition and typecast fail