Fixed bug on minimum boxes needed