reorganize to remove unnecessary if/else logic