some refactoring
added simple insert and edit functionality