Fixing bugs with api query