change code to work with older version of php