fix for optionals in queries