fixed insert bug and addedd logging