bug fixes to removing duplication logic