making background work without too much lag and loading time