replaced inRange method with generic comparison expression