initialized tmp[] = 0 correctly.