cleanup unnecessary code. reduce duplication.