Fixes bug in insertion