updating logic to reduce redundant layout events