updated function to meet the php older version