max() bug fix