Remove unnecessary end element