renamed things so that hard part occurs at the top