rebased everything from midhw9