Added 'insert' function and some debug