Made the calculateConnectedMass method