Improved works.php to check not only connection but data collection