Added empty detection