Hi Andre, Have you tried a multiway if-else statement? (See below) I appears it would be more efficient in execution than what you are currently doing. (If you can place the CASE_Xs in the order of most likely to occur frequently to least likely to occur frequently -- although I'm not sure if that will be possible in your application.) I kind of got lost in the fibers of this thread -- is your problem solved or are you still having trouble? if ( count == CASE_1 ) { // } else if ( count == CASE_2 ) { // } else if ( count == CASE_3 ) { // } else { // } Best regards, Ken Pergola -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads