sketched out the basic concept in code