Refactor custom APIs