Addresses bad alloc() error