Converted to using c++11
caught bad alloc