Problem 2 PHP procedure improved