refactored to C++11