refactoring virtual functions