Edited for c++11