final fix of duplicate logic