Simpler code with less repetition.