check for empty value before looping