implemented quadtree... not tested, hope it works