added comments to logic.php code