rm ifelse where returns NULL as error