this is a big fad block of code, I'd prefer to have code interleaved with explanations