using some lambda-expressions, removing unreacheable code, using some si...

using some lambda-expressions, removing unreacheable code, using some simplified expressions