Why not put this part of code to a separate method to make it easily maintain since it's used in the both if block?