Add error checking and edit toggle