Restructured solution to be more hierarchical