added option to choose how NAs in input are handled