fixing variable scope, too many ivar