function for transforming list to data.frame