You seems have duplicate code L.102-L.113 and L.117-L.127. Can you extract part of it in a method? (Maybe it's not possible ;)).