Removed usage of anonymous function to support php version 5.2.x.