more structure to the code, corrected switched scope values