replace function with function, model and view