error handling for 'foreach'