Updated main program to deal with unbalanced supply-demand