implemented vector grid function