Not really worth having a function for this. Just have two for loops in the above if statement instead. Then you don't need to check the useInt for each element.