Consider breaking this into multiple methods. This one's huge!