This code looks really familiar, was it taken from somewhere? And can we add tests for it?