handle empty and nil options in query