add code to compute maximum possible profit