replaced vertices from [] to ArrayList