some code moved outside worker.php