Edit function actually works correctly now