Fixing empty element bug