This entire block is a bit heavy to follow, mainly for lack of line-breaks, I can't at a quick-glance say where it would fit, but readability would be helped a bit if you could introduce a few blank lines at good spots.