added logic to the edit and judge