fix issues in foreach binding