Use max_n variable instead of magic numbers