backgd function wrong place