added encoding option to connection