escape dollar sign in password too, refractored code as well