consider extracting boolean expressions to local variables