fixed ifelse statements