fixed variable scope and default values