Restructured to not be so procedural