Refactor findMaxNubers function.