beginning of redundancy removal code