fixed max bug