packing algorithm working (huge room for optimization)