wrote functions to collect vertices