fixed to work on php 5.3