use bytearray rather than cast