Use Math.max to condense code