Maybe a few more comment lines here since it took me a bit of time to understand this