Sweet refactoring thanks to @kenoir