Implement solution preferred by @whit537.