Updated code with new controller