refactor bytes/chars utility