Fixed last element not closing bug