Simplify the code (variable bValid is not really interesting)