Refactor and add edit capability