fixed bug - bad allocation