Use api, and move it to it's own file