eliminated global variable by passing local variable to methods as argument