refactory controller