re-factored as a class