Refactored code to make the modal reusable. Added edit function.