Changed lapply() to sapply()