fixed issue with bad alloc