Update maxVar function