Refactoring to get a common approach