moved variable calculating div width for safety, and better handled offset width