I think it'd be easier to read if you'd split this code.