Fixed the Edit event function