refine zooming code