Refactoring according to Thibaut's comments