Threw the pattern sensor routine into its own function, sense_pattern