fixing pre-allocation issues