fix the max bug