optimize prefix search further