Refactoring for better generalisation.