adding $(data).each, using jquery each, rather than vanilla for loop