working vp tree implementation