Added scope checking to print statements.