working version - Needs more encoding for remote auth