Improved readability of the code thanks to Richard Clamp.