Fixed DAWNSCI-616, used equals to compare with empty mode and simplified
code