Interplay between rule learning and rule switching in a perceptual categorization task