improved zooming logic