replace conditional logic with existing function