refactored code, moved abstractable functions into parent class