extracted method to simplify code
small refactoring to improve code