re-factored controller