fixing max bug