Refactor api and options