Changed order of if else actions