Added logic for edit