added inheritance and working on memory management