fixed #9, and moved api to separate app