Fixing bug with optional query parameters