Fixes empty elements handling and a missing break