Implementation of remove vertex function