Moved variable declaration to function top.