Improved the PHP code