more robust encoding