fix stack allocation error