this should be outside the loop to avoid unnecessary queries