update code to work with older php version