Could use a newline here (and maybe a few above in this function) to separate sections of the function and make it a little more readable.