maybe for the for loop on line 49 you could extract that and make a method and use the method in the if statement on line 54