Refactored proxy.php