changed lambda functions to regular functions