Fixed the edit event logic