working version with bytes rather than strings