Set max as a variable

Can you review this change for me?