backgd function fixing