Bug fix on insert