Implemented part of insert-function