check for datasource.source, move to outside the for loop