empty check was looking at the wrong variable