Made the code compatible with older PHP versions