Converted code to php 5.3