Why does it take sometimes to see the objects in a dim room when we enter the room from bright sunlight outside?

In bright light, the size of the pupil is small to control the amount of lightentering the eye. When we enter a dim room, it takes sometime so that the pupil expands and allows more light to enter and help to see things clearly.