updated code to support php 5.3

the code not tested on php 5.3 yet!
but it should work...