refactoring using new vertex classes