Better packing algorithm