updating the code to work with previous version of php