Refactor doc controller