assignment 3: finished best function