completely re-factored master