fix code to fit into mvc structure