fixed bugs and added production of scope file