fixing query and graphs