Make the logic more cleaner.