replace lambda function with runtime created equivalent. Downgare requirements to php 5.2