Put animation code in animate function and added logging of background values