changed l2 to sqrt(l2) but I don't think this is right.