added lapply and tests