Remove code duplicated between conditionals