with thanks to @Twlthomas