decoupled main building function
added docs for python api