changed functions to c++11 lambdas