move embedding code to a python module