Change for loop to lapply statement... efficiency, function applicable to other things...