Fixed bug: insertions are now handled correctly