changed as.data.frame.dataset - simplified and corrected