fixing bug in bg script