update to check the variables before looping

Signed-off-by: Tass Skoudros <tass@skystack.com>