replace for + wrong sizeof with a switch

`sizeof(invalid)` returns the size of a `char*` and not of the string pointed to.
looks this line can be removed.