improve zooming and panning function