Refactoring to generic