some refactoring + working on edit functions