Refactor get_password