refactor embedding functionality to use regexp