improved check.php