quadtree optimized
code in mean cleaned up