Working edit functionality
Refactored