Looks like the similar code are repeated many times.
Could you make Line21 - Line43 more compact one?