added some comments and changed some function names
added tests for weighted and the weighted function