Updated code + added queryType