refactoring: use Math.max to compute the maximum of two integer values