Updated logic.php