improved proxy code