slightly changed levels, removed three global variables