Refactoring a bit
Generalizing type