implement firstfit and bestfit