optimized check.php