Fixed: loop length variable (MAX) declaration.