Use clearBounds instead of create new geometry.
Don't remove style (display:none) when not exists.
Unify the variable declaration.