Changed lapply to llply intead, same result, I prefer to use plyr