Added a helper function, and commented my plan of attack.