Slight logic fix, should be min of capacity and work, since work includes work being worked on.