Fix insert function.