better if...else logic