sapply replaced with vapply.