Change midlleware to controller