CHANGED:applied the min/close window function