improve readability if/else logic