improved script.php