refactor numLongChain to use lambda instead of where binding