edited lottery.m, no major change in function