move functionality out of main.cpp
add invoke method api