Add error handling to compact and edit