Source code Refactoring. Extracted common functionality