query method returning array bug