refactoring to use extension method