Real nut to crack, took some real serious brain power to find the code reduction path