fixed the code to use Inheritance