refactoring, moving duplicate code to abstract class