Better use of unapply(). Still not sure this is the best way