Bug fix: num of bytes needed was too large
Another algorithm