fixed crash because of too much stack memory allocation