Changing the use of an anonymous function to php 5.2.8 compatible code