Refactored code up to abstract superclass