changing code to work with php5.2