protect foreach loop with isset