util: move variable declaration out of for-loop