Added check for code not within a function.