refactored code | added functionality to fix inheritance issue