some refactorings please invert if fails