adding refactored changes to support zooming: refactored to put other code in proper files