Refactoring after Simon's comments