refatoring of prefix resolving