remove duplicated code. add render option.