Fixed a long standing bug in appending and inserting action