I'd like to try to simplify this block if possible, or at least have a comment explaining what is going on.