Improvement based on @le717's feedback.