Minor refactor to handle edit state correctly