Fix query for stm & respond with count of results