fixed basic functions, need to deal with all NAs