update logic for autoresize  background