Added function for computing max potential