As discussed, could put this as a helper function, also I seem to have missed out the `bytes_to_str` which is presumably there for a reason...