now handles multiple positions and weights