Improved prefix generation