Extracted some commonly used code into base class