Refactor api into helpers