set ref_length correctly