Adjusted code fro PHP 5.6