use Math.max rather than an if statement