fixed outscope value error, modify code against some of the style conventions in PEP 8