Minor improvement in the insert function.