A bit of refactoring and implementation