Add missing brackets for weights calculation