Refactory controller and services