removed global i, optimized change function, renamed variables in scramble, prettier format for interleave, declared i where used