RB insert fix function