added weight algorithm