Source code refactoring. Extracted common functionality into merged methods

Source code refactoring. Extracted common functionality into merged methods