Re-factored for chapter structure