this is important because it runs while transforming the mesh in editmode. also made this code a bit more efficient.