fixed NA treatment in read, prettified code