improve performance so that scan_binary can be faster than unpack