fix infinite looping bug for slow (large) datasets; add console.logs for future debugging