refactoring code base to abstract base class and util function to improve code reusage.