quickfix of ugly bug in foreach