evaluate function only in valid region