fixed "ifelse" statement