refactorred class hierarchy