A little code optimization: instead of 'b=FALSE; if(a) b=TRUE' use just 'b=a'.