Range query, but have bugs