insert and read function