insert function implemented by Pucong