Added additional implementation, thanks to Chris Dollin.