Tested code with a different weight variable