ENH: improve getvertices function