make the code simple and fix the insert returned bug