Moved if else logic to new pattern