fixed bad memory allocation bug, thanks to giv