updated to log-weights to increase the accuracy