Get rid of duplicate logic