Changed if else logic