Added logic for form edit