refactored proxy script