here is the simpler implementation. the comments make it super clean/clear - probs more than before