Fixing query adding iid instead of id