Copied the logic from the previous page into this one.