restyled code so it's more c++11.