copy the code from page d1