Add proxy support
split big function into smaller ones, handle more exception