This was a tough design problem, to begin with, with too many decision points in too short a distance. To…