fixed handling of empty elements