Inheritance not working properly