refactoring to match madeleine's code