static variable changed to local variable

using local variable will be better. take a look