implemented an insertion function