Fixed bug to make code work on older PHP versions.