Functionally it looks good, I have two comments though.Hi,
1) you don't need to revert 151b8c5ba1eb, the commit is a proper fix
per se but incomplete, please add your change on top of it,
2) minimizing the lines of code by removing duplicates is always good,
so here a better and complete fix will be like the following one: