added weight parameter when necessary