Fix crash when empty elements