refactor to lambda and remove constant use warning