fix record insertion in database