fix max computation