added sapply correctly