refactor into api folder