iolist_to_binary can also take binaries, so we don't need the case statement.