fixed allocation bug