Modified version for higher PHP versions