Refactor topics controller